package main

import (
	"natsmicro/conf"
	"sync"

	"github.com/gogf/gf/frame/g"
	"github.com/gogf/gf/util/grand"
	"github.com/nats-io/stan.go"
)

var donewg sync.WaitGroup

func main() {

	ns, err := stan.Connect("test-cluster", "myI3D"+grand.Digits(3), stan.NatsURL(conf.NatsUrl))

	if err != nil {
		println(err.Error())
	}

	NN := 1000
	for i := 0; i < NN; i++ {
		// Simple Async Subscriber
		j := i
		sub1, _ := ns.QueueSubscribe(conf.SubjectNameSub, "aaa", func(m *stan.Msg) {
			// g.Log().Info(m.Data)
			g.Log().Info(j)

		})
		_ = sub1
	}
	select {}

	ns.Close()
}
